-- @owner:宋菲
-- @date:2024-03-15
-- @testpoint:1.测试更新函数，函数名称大小写不敏感，合理报错

--开启参数
set enable_ignore_case_in_dquotes to on;

--创建表和函数;expect:成功(9 rows)
create table t_ignore_case_in_dquotes_alter_case0023(col1 int,col2 int); 

create function f_ignore_case_in_dquotes_alter_case0023_1("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(1,1);
    return col;
end;
$$ language plpgsql;
/

create function f_ignore_case_in_dquotes_alter_case0023_2("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(2,2);
    return col;
end;
$$ language plpgsql;
/

create function f_ignore_case_in_dquotes_alter_case0023_3("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(3,3);
    return col;
end;
$$language plpgsql;
/

create function "f_ignore_case_in_dquotes_alter_case0023_!@#$%^&*()?<>:;=+-_4"("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(4,4);
    return col;
end;
$$language plpgsql;
/

create function "f_ignore_case_in_dquotes_alter_case0023_''_5"("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(5,5);
    return col;
end;
$$language plpgsql;
/

create function "f_ignore_case_in_dquotes_alter_case0023_""""""_6"("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(6,6);
    return col;
end;
$$language plpgsql;
/

create function "f_ignore_case_in_dquotes_alter_case0023_''""_7"("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(7,7);
    return col;
end;
$$language plpgsql;
/

create function f_ignore_case_in_dquotes_alter_case0023_8("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(8,8);
    return col;
end;
$$language plpgsql;
/

--step1:更新函数名为全小写;expect:成功 
create or replace function "f_ignore_case_in_dquotes_alter_case0023_1"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(10,10);
    return col;
end;
$$language plpgsql;
/

--step2:更新函数名为全大写;expect:成功
create or replace function "F_IGNORE_CASE_IN_DQUOTES_ALTER_CASE0023_2"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(20,20);
    return col;
end;
$$language plpgsql;
/

--step3:更新函数名为大小写混合;expect:成功
create or replace function "f_IgNOrE_CasE_IN_dquotes_alter_cASe0023_3"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(30,30);
    return col;
end;
$$language plpgsql;
/

--step4:更新函数名带有特殊符号;expect:成功
create or replace function "f_IGNORE_CASE_IN_dquotes_alter_CASE0023_!@#$%^&*()?<>:;=+-_4"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(40,40);
    return col;
end;
$$language plpgsql;
/

--step5:更新函数名带有单引号;expect:成功
create or replace function "f_IGNORE_CASE_IN_dquotes_alter_CASE0023_''_5"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(50,50);
    return col;
end;
$$language plpgsql;
/

--step6:更新函数名带有双引号;expect:成功
create or replace function "f_IGNORE_CASE_IN_dquotes_alter_CASE0023_""""""_6"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(60,60);
    return col;
end;
$$language plpgsql;
/

--step7:更新函数名带有单引号、双引号混合;expect:成功
create or replace function "F_IGNORE_CASE_IN_dquotes_alter_case0023_''""_7"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_alter_case0023 values(70,70);
    return col;
end;
$$language plpgsql;
/

--step8:执行函数;expect:成功(7 rows)
call f_ignore_case_in_dquotes_alter_case0023_1(1);

call f_ignore_case_in_dquotes_alter_case0023_2(1);

call f_ignore_case_in_dquotes_alter_case0023_3(1);

call "f_ignore_case_in_dquotes_alter_case0023_!@#$%^&*()?<>:;=+-_4"(1);

call "f_ignore_case_in_dquotes_alter_case0023_''_5"(1);

call "f_ignore_case_in_dquotes_alter_case0023_""""""_6"(1);

call "f_ignore_case_in_dquotes_alter_case0023_''""_7"(1);

--step9:查询执行结果;expect:成功

select * from t_ignore_case_in_dquotes_alter_case0023 order by 1;

--清理环境:expect:成功(9 row)
drop function f_ignore_case_in_dquotes_alter_case0023_1;

drop function f_ignore_case_in_dquotes_alter_case0023_2;

drop function f_ignore_case_in_dquotes_alter_case0023_3;

drop function "f_ignore_case_in_dquotes_alter_case0023_!@#$%^&*()?<>:;=+-_4";

drop function "f_ignore_case_in_dquotes_alter_case0023_''_5";

drop function "f_ignore_case_in_dquotes_alter_case0023_""""""_6";

drop function "f_ignore_case_in_dquotes_alter_case0023_''""_7";

drop function f_ignore_case_in_dquotes_alter_case0023_8;

drop table t_ignore_case_in_dquotes_alter_case0023;

--关闭参数
set enable_ignore_case_in_dquotes to off;
